/* GUI CONVERTED from recrms.p (converter v1.76) Mon May 27 10:17:22 2002 */
/* recrms.p - Repetitive create Master Schedule from Sequence File      */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                  */
/* All rights reserved worldwide.  This is an unpublished work.         */
/* $Revision: 1.7.1.5 $                                                 */
/*V8:ConvertMode=Report                                                 */
/* REVISION: 7.0   LAST MODIFIED 12/02/91    BY: SMM       *F230        */
/* REVISION: 7.0   LAST MODIFIED 04/07/92    BY: smm       *F366*       */
/* REVISION: 7.0   LAST MODIFIED 04/08/92    BY: smm       *F368        */
/* REVISION: 7.3   LAST MODIFIED 12/18/92    BY: emb       *G467*       */
/* REVISION: 7.3   LAST MODIFIED 08/09/93    BY: emb       *GE01*       */
/*                               10/12/93    BY: jzs       *GG27*       */
/* REVISION: 7.3   LAST MODIFIED 03/24/94    BY: pma       *GJ20*       */
/*                               08/27/94    BY: bcm       *GL62*       */
/* REVISION: 7.5   LAST MODIFIED 01/03/95    BY: mwd       *J034*       */
/*                               05/01/96    BY: jzs       *H0KR*       */
/* REVISION: 8.5      LAST MODIFIED: 10/24/96   BY: *J16V* Murli Shastri   */
/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane       */
/* REVISION: 8.6E     LAST MODIFIED: 05/20/98   BY: *K1Q4* Alfred Tan      */
/* REVISION: 8.6E     LAST MODIFIED: 10/04/98   BY: *J314* Alfred Tan      */
/* REVISION: 9.1      LAST MODIFIED: 08/19/99   BY: *N01B* John Corda      */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00   BY: *N08T* Annasaheb Rahane   */
/* REVISION: 9.1      LAST MODIFIED: 07/25/00   BY: *N0GD* Ganga Subramanian  */
/* Old ECO marker removed, but no ECO header exists *F0PN*                    */
/* $Revision: 1.7.1.5 $    BY: Katie Hilbert      DATE: 05/15/02  ECO: *P06H*  */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

/************************************************************************/


/*GUI preprocessor directive settings */
&SCOPED-DEFINE PP_GUI_CONVERT_MODE REPORT

{mfdtitle.i "2+ "}

/* PREPROCESSOR USED FOR REPORTS WITH SIMULATION OPTION */
&SCOPED-DEFINE simulation true

define variable site       like rps_site no-undo.
define variable site1      like rps_site no-undo.
define variable line       like rps_line no-undo.
define variable line1      like rps_line no-undo.
define variable part       like rps_part no-undo.
define variable part1      like rps_part no-undo.
define variable due        like rps_due_date no-undo.
define variable due1       like rps_due_date no-undo.
define variable msg1       as character format "x(12)" no-undo.
define variable update_yn  like mfc_logical initial yes
                           label "Update" no-undo.
define variable update-seq like mfc_logical
                           label "Delete Line Schedule" no-undo.
define variable um         like pt_um.
define variable desc2      like pt_desc2.
define variable rpsqtyreq  like rps_qty_req.

define new shared workfile rp like rps_mstr.


/*GUI preprocessor Frame A define */
&SCOPED-DEFINE PP_FRAME_NAME A

FORM /*GUI*/ 
   
 RECT-FRAME       AT ROW 1 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1 COLUMN 3 NO-LABEL VIEW-AS TEXT SIZE-PIXELS 1 BY 1
 SKIP(.1)  /*GUI*/
site       colon 23
   site1      colon 46 label {t001.i}
   line       colon 23
   line1      colon 46 label {t001.i}
   part       colon 23
   part1      colon 46 label {t001.i}
   due        colon 23
   due1       colon 46 label {t001.i}
   skip(1)
   update_yn  colon 23
   update-seq colon 23
   skip(1)
with frame a side-labels width 80 NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-a-title AS CHARACTER INITIAL "".
 RECT-FRAME-LABEL:SCREEN-VALUE in frame a = F-a-title.
 RECT-FRAME-LABEL:HIDDEN in frame a = yes.
 RECT-FRAME:HEIGHT-PIXELS in frame a =
  FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME a = FRAME a:WIDTH-CHARS - .5.  /*GUI*/

/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME



/* SET EXTERNAL LABELS */
setFrameLabels(frame a:handle).

assign
   msg1  = getTermLabel("CONT",12)
   site  = global_site
   site1 = global_site
   due   = today.

mainloop:
repeat:

   if due1  = hi_date then due1 = ?.
   if due   = low_date then due = ?.
   if part1 = hi_char then part1 = "".
   if site1 = hi_char then site1 = "".
   if line1 = hi_char then line1 = "".

   update
      site
      site1
      line
      line1
      part
      part1
      due
      due1
      update_yn
      update-seq
   with frame a.

   bcdparm = "".

   {gprun.i ""gpquote.p"" "(input-output bcdparm,10,
        site, site1, line, line1, part, part1, string(due),
        string(due1), string(update_yn), string(update-seq),
        null_char, null_char, null_char, null_char, null_char,
        null_char, null_char, null_char, null_char, null_char)"}

   if due1  = ?  then due1  = hi_date.
   if due   = ?  then due   = low_date.
   if part1 = "" then part1 = hi_char.
   if site1 = "" then site1 = hi_char.
   if line1 = "" then line1 = hi_char.

   if not batchrun then do:
      {gprun.i ""gpsirvr.p""
         "(input site, input site1, output return_int)"}
      if return_int = 0 then do:
         next-prompt site with frame a.
         undo mainloop, retry mainloop.
      end.
   end.

   if update-seq and not update_yn
   then do:
      /* Line schedule will be deleted without update to repetitive */
      {pxmsg.i &MSGNUM=270 &ERRORLEVEL=2}
   end.

   /* OUTPUT DESTINATION SELECTION */
   {gpselout.i &printType = "printer"
               &printWidth = 132
               &pagedFlag = " "
               &stream = " "
               &appendToFile = " "
               &streamedOutputToTerminal = " "
               &withBatchOption = "yes"
               &displayStatementType = 1
               &withCancelMessage = "yes"
               &pageBottomMargin = 6
               &withEmail = "yes"
               &withWinprint = "yes"
               &defineVariables = "yes"}
/*GUI*/ RECT-FRAME:HEIGHT-PIXELS in frame a = FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.

   {mfphead.i}

   /* Delete Repetitive Schedules not supported by the Line Schedule */
   {gprun.i ""recrmsa.p""
      "(site, site1, line, line1, part, part1, due, due1, update_yn)"}

   {gprun.i ""recrmsb.p""
      "(site, site1, line, line1, part, part1, due, due1, update_yn,
        update-seq)"}

   /* Display Schedule Created */
   do for rp:
      FORM /*GUI*/ 
         rps_part
         pt_desc1
         rps_rel_date
         rps_due_date
         rps_qty_comp column-label "Previous!Repetitive!Schedule"
         rps_qty_req  column-label "Production Line!Schedule"
         um
         rpsqtyreq    column-label "Resulting!Repetitive!Schedule"
      with STREAM-IO /*GUI*/  frame b width 132 down
         no-attr-space no-box.

      /* SET EXTERNAL LABELS */
      setFrameLabels(frame b:handle).

      for each rp
         exclusive-lock
            where (rps_site >= site and rps_site <= site1)
              and (rps_line >= line and rps_line <= line1)
              and (rps_part >= part and rps_part <= part1)
            break by rps_site
                  by rps_line
                  by rps_part
                  by rps_due_date
         with frame b:

         do with frame c:

          /* SET EXTERNAL LABELS */
          setFrameLabels(frame c:handle).

            if first-of(rps_line) then do:

               if page-size - line-counter < 5 then page.

               display
                  rps_site
                  rps_line
               with frame c side-labels STREAM-IO /*GUI*/ .

               find ln_mstr where ln_line = rps_line
                  and ln_site = rps_site no-error.

               if available ln_mstr then
                  display
                     ln_desc no-label
                  with frame c STREAM-IO /*GUI*/ .
            end.

            if first-of(rps_part) then do:
               if page-size - line-counter < 2 then do:
                  page.
                  display
                     rps_site
                     rps_line
                     msg1 @ ln_desc
                  with frame c STREAM-IO /*GUI*/ .
               end.

               display rps_part WITH STREAM-IO /*GUI*/ .
               assign
                  um    = ""
                  desc2 = "".
               find pt_mstr no-lock where pt_part = rps_part no-error.
               if available pt_mstr then display pt_desc1 WITH STREAM-IO /*GUI*/ .
               if available pt_mstr then
                  assign
                     um = pt_um
                     desc2 = pt_desc2.
            end.
            else do:
               if desc2 > "" then display desc2 @ pt_desc1 WITH STREAM-IO /*GUI*/ .
               desc2 = "".
            end.

            if page-size - line-counter < 1 then do:
               page.
               display
                  rps_site
                  rps_line
                  msg1 @ ln_desc
               with frame c STREAM-IO /*GUI*/ .
            end. /* do with */
            display
               rps_part
               msg1 @ pt_desc1
            with frame b STREAM-IO /*GUI*/ .
         end.

         display
            rps_rel_date
            rps_due_date
            rps_qty_comp
            rps_qty_req um WITH STREAM-IO /*GUI*/ .

         display rps_qty_req @ rpsqtyreq WITH STREAM-IO /*GUI*/ .

         down 1.

         if last-of(rps_part) then do:
            if desc2 > "" then display desc2 @ pt_desc1 WITH STREAM-IO /*GUI*/ .
            down 1.

            /*REAPPLY SCHEDULE CUMS COMPLETED*/
            /* IN ORDER TO AVOID STANDARD REPETITIVE USERS TO UPDATE
               REPETITIVE MASTER RECORDS BASED ON ADVANCED REPETITIVE
               LOGIC(CONSUME-EARLIEST-OPEN) THE CHECK FOR INSTALLATION
               OF ADVANCED REPETITIVE MODULE HAS BEEN INTRODUCED */
            if update_yn and can-find(mfc_ctrl where
               mfc_field = "rpc_using_new" and mfc_logical) then do:
               {gprun.i ""rerpmtb.p""
                  "(input rps_part, input rps_site, input rps_line)"}
            end.
         end. /* if last-of */
         delete rp.
      end. /* For each rp */

      {mfrtrail.i}
   end. /* do for rp */
end. /* REPEAT */
